import 'package:get/get.dart';
import 'package:pet_app/base/base_controller.dart';
import 'package:pet_app/model/article.dart';
import 'package:pet_app/net/http.dart';
import 'package:pet_app/widget/loading_widget.dart';

class ArticleDetailLogic extends BaseController {
  late Article article;
  bool isLoading = true;

  @override
  void initData() {
    if(Get.arguments['article'] != null){
      article = Get.arguments['article'];
      isLoading = false;
      update();
    }else{
      int breedId = Get.arguments['breedId'];
      getArticleDetail(breedId);
    }
  }

  getArticleDetail(int breedId) {
    Loading.show();
    Http().client.getArticleByBreedId(breedId).then((value) {
      article = value?.data ?? Article();
      Loading.dismiss();
      isLoading = false;
      update();
    });
  }
}
